import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/manager/xindong_user_controller.dart';
import 'package:xindong/models/user/xindong_user.dart';
import 'package:xindong/widgets/dialog/xindong_base_sheet.dart';
import 'package:xindong/widgets/gift/xindong_songli_controller.dart';
import 'package:xindong/widgets/gift/view/xindong_songli_body.dart';
import 'package:xindong/widgets/gift/view/xindong_songli_util_bar.dart';

class XinDongSongLiSheet extends StatefulWidget {
  const XinDongSongLiSheet({super.key});

  XinDongSongLiSheet.show({
    super.key,
    required XinDongUser user,
    required XinDongSongLiSuccessFunction onSuccess,
  }) {
    final controller = Get.put(XinDongSongLiController());
    controller.selectGift = null;
    controller.selectCount = 1;
    controller.user = user;
    controller.onSuccess = onSuccess;
    showSheetDialog(sheet: this);
  }

  @override
  State<XinDongSongLiSheet> createState() => _XinDongSongLiSheetState();
}

class _XinDongSongLiSheetState extends State<XinDongSongLiSheet> {
  @override
  void initState() {
    super.initState();
    XinDongSongLiController.to.requestGiftList();
    XinDongUserController.to.requestUserVolley();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        const XinDongSongLiBody(),
        const XinDongSongLiToolBar(),
        // 安全区域，使用MediaQuery.of(context).padding.bottom，键盘抬起时自动改变高度
        SizedBox(height: MediaQuery.of(context).padding.bottom),
      ],
    );
  }
}
